package com.lechuang.rpc.interceptor;

import com.lechuang.common.constant.BaseConstant;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;

/**
 * <p>
 *     feign调用traceId传递
 * </p>
 * @author liaoningbo
 * @since 2023/12/19
 */
@Slf4j
public class FeignRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        String traceId = MDC.get(BaseConstant.TRACE_ID);
        template.header("traceId", traceId);
    }
}
